﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Resources;
using System.Windows.Shapes;
using Newtonsoft.Json;
using HalloJSON.CommenData;
namespace HalloJSON
{
    public class WinClient
    {
        // private string url;
        public RootObject rootObject {get; set;}
        public WinClient() 
        {
         this.callUrl(); 
        }
        private void callUrl()
        {
            WebClient webClient = new WebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            webClient.DownloadStringAsync(new Uri(string.Format("https://kunden.multicity-carsharing.de/kundenbuchung/hal2ajax_process.php?zoom=10&lng1=&lat1=&lng2=&lat2=&stadtCache=&mapstation_id=&mapstadt_id=&verwaltungfirma=&centerLng=13.382322739257802&centerLat=52.50734843957503&searchmode=buchanfrage&with_staedte=false&buchungsanfrage=N&lat=52.50734843957503&lng=13.382322739257802&instant_access=J&open_end=J&objectname=multicitymarker&ignore_virtual_stations=J&before=null&after=null&ajxmod=hal2map&callee=getMarker")));
            
        }

        void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            Console.WriteLine("fdgsd");
            
            if (!string.IsNullOrEmpty(e.Result))
            {
                rootObject = new RootObject();
                var readObject = JsonConvert.DeserializeObject<RootObject>(e.Result);
                rootObject = readObject;
            }
        }
        /*
        public RootObject getRootObject() 
        {
            return rootObject;
        }
        */


    }
  
}
